流的定位tellg() / tellp()、seekg() / seekp() |
您所在的位置:网站首页 › tellg tellp › 流的定位tellg() / tellp()、seekg() / seekp() |
获取流位置
– tellg() / tellp() 可以用于获取输入 / 输出流位置 (pos_type 类型 ) – 两个方法可能会失败,此时返回 pos_type(-1) **tellp()**返回当前关联的 streambuf 对象的输出位置指示器。 若出现失败则为 pos_type(-1) 。 示例: #include #include int main() { std::ostringstream s; std::cout std::string str = "Hello, world"; std::istringstream in(str); std::string word1, word2; in >> word1; in.seekg(0); // 回溯 in >> word2; std::cout |
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |